package com.scut.fy.admin.controller;


import com.scut.fy.admin.model.entity.SysRole;
import com.scut.fy.admin.model.entity.SysUser;
import com.scut.fy.admin.service.ISysRoleService;
import com.scut.fy.common.web.model.HttpResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jy
 * @since 2021-09-04
 */
@RestController
@RequestMapping("/sysRole")
public class AdminSysRoleController {

    @Resource
    private ISysRoleService sysRoleService;

    @PostMapping("/findByUserName")
    public HttpResult<List<SysRole>> findSysRolesByUserName(String userName) {
        SysUser sysUser = new SysUser();
        sysUser.setUserName(userName);
        return new HttpResult<>(sysRoleService.getRolesByUser(sysUser));
    }

    @PostMapping("/findByUserId")
    public HttpResult<List<SysRole>> findSysRolesByUserId(long userId) {
        SysUser sysUser = new SysUser();
        sysUser.setUserId(userId);
        return new HttpResult<>(sysRoleService.getRolesByUser(sysUser));
    }
}

